
/*
 * Copyright (C) Zhu Jiashun
 * Copyright (C) Zaver
 */

#ifndef UTIL_H
#define UTIL_H

// max number of listen queue
#define LISTENQ 1024 // 半监听队列大小

#define BUFLEN 8192 // 缓冲区大小

#define DELIM "="

#define ZV_CONF_OK 0
#define ZV_CONF_ERROR 100

#define MIN(a, b) ((a) < (b) ? (a) : (b))

// 配置
struct zv_conf_s
{
    void *root;
    int port;
    int thread_num;
};

typedef struct zv_conf_s zv_conf_t;

int open_listenfd(int port); // 监听
int make_socket_non_blocking(int fd); // 设置非阻塞

int read_conf(char *filename, zv_conf_t *cf, char *buf, int len); // 读取配置
#endif
